package com.it.App.exception;

import com.it.App.vo.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author: Coke
 * @DateTime: 2023/11/23/9:31
 * @注释: 全局异常处理器，处理项目中抛出的业务异常
 **/
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    
    /**
     * 捕获业务异常

     * @param e:
     * @return Response<?>
     * @author: CaoYouGen
     * @DateTime: 2023/11/23 9:33
     */
    @ExceptionHandler
    public Response<?> exceptionHandler(BaseException e){
        log.error("异常信息：{}", e.getMessage());
        return Response.error(e.getMessage());
    }
}
